package com.angle3d;

/**
 * Base abstract class for scene objects.
 * A scene object is a renderable entity; it should be attached to a {@link Node} of the scene graph in order to be rendered.
 * @author Alessandro Boccalatte
 * @see {@link Node#setSceneObject(SceneObject)}
 */
public abstract class SceneObject {

	protected ShaderProgram mShader;
	
	/**
	 * Sets the {@link ShaderProgram} to be used by this scene object for rendering.
	 * @param shader a ShaderProgram
	 */
	public void setShaderProgram(ShaderProgram shader) {
		mShader = shader;
	}
	
	/**
	 * Returns the {@link ShaderProgram} used by this SceneObject.
	 * @return the ShaderProgram used by this SceneObject.
	 */
	public ShaderProgram getShaderProgram() {
		return mShader;
	}
	
	/**
	 * Renders this SceneObject.
	 * @param view the {@link View3D} in which this SceneObject will be rendered.
	 * @param projection the projection matrix.
	 * @param modelview the modelview matrix.
	 */
	public void render(View3D view, Matrix4 projection, Matrix4 modelview) {
		if (mShader != null) {
			mShader.bind();
			mShader.setUniformValue("Projection", projection);
			mShader.setUniformValue("ModelView", modelview);	
		}
	}
	
	/**
	 * Updates the SceneObject.
	 * @param dt a time delta since last update (in seconds)
	 */
	public void update(float dt) {}
}
